//
//  CommentViewController.m
//  grainHouse
//
//  Created by 北风 on 14-10-18.
//  Copyright (c) 2014年 北风. All rights reserved.
//

#import "CommentViewController.h"

@interface CommentViewController ()

@property(nonatomic,retain)ZYQSphereView *sphereView;
@property(nonatomic,retain)NSTimer *timer;

@end

@implementation CommentViewController

- (void)dealloc{
    [_sphereView release];
    [_timer release];
    [super dealloc];
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        
        self.couldArray = [NSMutableArray array];
    
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    for (int i = 0; i < 100; i ++) {
        
        NSString *strinb = [NSString stringWithFormat:@"%d云效果☁️",i];
        [self.couldArray addObject:strinb];
        
    }
    NSLog(@"😊😊😊😊😊😊😊😊😊－－－－－－－%@",self.couldArray);
    [self sphereViewColoud];
    
    
}



-(void)sphereViewColoud{
    
    self.sphereView = [[ZYQSphereView alloc] initWithFrame:CGRectMake(10, 64, 320, 320)];
    self.sphereView.center = CGPointMake(self.view.center.x, self.view.center.y + 30);
    
    NSMutableArray *views = [[NSMutableArray alloc] init];
    for (int i = 0; i < self.couldArray.count; i++) {
        UIButton *subV = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
        subV.backgroundColor = [UIColor colorWithRed:arc4random_uniform(100) / 100. green:arc4random_uniform(100) / 100. blue:arc4random_uniform(100) / 100. alpha:0.8];
        [subV setTitle:self.couldArray[i] forState:UIControlStateNormal];
        
        subV.titleLabel.font = [UIFont systemFontOfSize:12];
        subV.titleLabel.lineBreakMode = 0;
        [subV.titleLabel sizeToFit];
        subV.titleLabel.textColor = [UIColor colorWithRed:19.0 / 255.0 green:12 / 255.0 blue:14 / 255.0 alpha:0.8];
        subV.layer.masksToBounds = YES;
        subV.layer.cornerRadius = 3;
        [subV addTarget:self action:@selector(subVClick:) forControlEvents:UIControlEventTouchUpInside];
        [views addObject:subV];
        [subV release];
    }
    
    [self.sphereView setItems:views];
    
    self.sphereView.isPanTimerStart = YES;
    [views release];
    [self.view addSubview:self.sphereView];
    [self.sphereView timerStart];
    
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake((self.view.frame.size.width - 120) / 2, self.view.frame.size.height - 50, 120, 30);
    [self.view addSubview:btn];
    btn.backgroundColor = [UIColor whiteColor];
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = [[UIColor orangeColor] CGColor];
    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [btn setTitle:@"start/stop" forState:UIControlStateNormal];
    btn.selected = NO;
    [btn addTarget:self action:@selector(changePF:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

- (void)changePF:(UIButton*)sender{
    if ([self.sphereView isTimerStart]) {
        [self.sphereView timerStop];
    }
    else{
        [self.sphereView timerStart];
    }
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
